package cn.tedu.rabbitmqboot.m1;


import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class Main {
    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @Bean
    public Queue helloworldQueue(){
        return new Queue("helloworld", false);
    }

    @Autowired
    private Producer producer;

    /**
     * 在spring执行完扫描,创建完所有对象,完成所有的注入后
     * 会自动执行 @PostConstruct方法
     * */
    @PostConstruct
    public void test(){
        producer.send();
    }


}
